/**
 * 使用promise对小程序api进行封装
 * @param{function}-fn 传入的小程序api 
 * @return {promise} - 返回promise状态
 * @example 
 */

const promise = function wxPromise(fn) {
	return function(obj = {}) {
		return new Promise((resolve, reject) => {
			obj.success = function(res) {
				resolve(res)
			}
			obj.fail = function(res) {
				reject(res);
			}
			fn(obj);
		});
	}
}
export default {
	uniPromise: promise
}
